package com.bluemsun.naturallanguageprocessing.service.impl;

import com.bluemsun.naturallanguageprocessing.common.ServerResponse;
import com.bluemsun.naturallanguageprocessing.dao.NoticeMapper;
import com.bluemsun.naturallanguageprocessing.entity.Notice;
import com.bluemsun.naturallanguageprocessing.service.INoticeService;
import com.bluemsun.naturallanguageprocessing.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：hj
 * @date ：Created in 2021/4/29 19:20
 * @description：公告
 * @modified By：
 * @version: $
 */
@Service("INoticeService")
public class NoticeServiceImpl implements INoticeService {

    @Autowired
    NoticeMapper noticeMapper;

    @Override
    public ServerResponse getList(Integer pageSize, Integer pageNum) {
         PageVO pageVo  = new PageVO(pageNum,pageSize,noticeMapper.Count());
         pageVo.setList(noticeMapper.getList(pageSize, pageVo.getStartIndex()));
         return ServerResponse.createBySuccess(pageVo);
    }

    @Override
    public ServerResponse updateList(Notice notice) {
        noticeMapper.setNotice(notice);
        return ServerResponse.createBySuccess();
    }

    @Override
    public ServerResponse insertNotice(Notice notice) {
        noticeMapper.insertNotice(notice);
        return ServerResponse.createBySuccess();
    }
}
